package cn.kgc.ssm.controller;

import cn.kgc.ssm.dto.PageDTO;
import cn.kgc.ssm.entity.SysUser;
import cn.kgc.ssm.entity.User;
import cn.kgc.ssm.service.UserService;
import cn.kgc.ssm.util.LayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author: mosin
 * @version: v1.0  2022/7/11
 */
@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;


    // 查询所有用户信息
    @RequestMapping("all")
    @ResponseBody
    public LayUtil selectAll(PageDTO pageDTO) {
        return userService.findALL(pageDTO);
    }

    // 添加用户信息

    @RequestMapping("add")
    @ResponseBody
    public Object addUser(SysUser user) {
        System.out.println(user);
        Map<String, Object> map = userService.addUserInfo(user);
        return  map;
    }



    @RequestMapping("delete")
    @ResponseBody
    public Object deleteById(Integer id) {
        return userService.deleteById(id);
    }

}
